//
//  FogotPasswordViewController.m
//  02-HomeWork
//
//  Created by dllo on 16/7/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FogotPasswordViewController.h"

@interface FogotPasswordViewController () <UITextFieldDelegate>
@property (nonatomic, strong)UITextField *phoneTextField;
@property (nonatomic, strong)UITextField *verificationTextField;
@end

@implementation FogotPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   // 返回按钮
    UIButton *backToLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backToLoginButton.frame = CGRectMake(10, 30, 60, 40);
    [backToLoginButton setTitle:@"< 返回" forState:UIControlStateNormal];
    [backToLoginButton setTitleColor:[UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [backToLoginButton addTarget:self action:@selector(backToLoginButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backToLoginButton];
  // 验证手机
    UILabel *verificationPhone = [[UILabel alloc] initWithFrame:CGRectMake(50, 70, self.view.frame.size.width, 50)];
    CGPoint point = verificationPhone.center;
    point.x = self.view.frame.size.width / 2;
    verificationPhone.center = point;
    verificationPhone.text = @"验证手机";
    verificationPhone.textAlignment = NSTextAlignmentCenter;
    verificationPhone.font = [UIFont systemFontOfSize:30];
    [self.view addSubview:verificationPhone];
   // 手机
    UIImageView *phoneImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 140, 50, 50)];
    phoneImageView.image = [UIImage imageNamed:@"phone1.png"];
    
    [self.view addSubview:phoneImageView];
    self.phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(60, 140, 310, 50)];
    self.phoneTextField.placeholder = @"手机号 （仅支持中国大陆号）";
    self.phoneTextField.textColor = [UIColor grayColor];
    self.phoneTextField.delegate = self;
    [self.view addSubview:self.phoneTextField];
    
    UILabel *phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 190, self.view.frame.size.width - 30, 1)];
    phoneLabel.backgroundColor = [UIColor grayColor];
    phoneLabel.alpha = 0.5;
    [self.view addSubview:phoneLabel];
    
   // 验证码
    UIImageView *verificationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 200, 50, 50)];
    verificationImageView.image = [UIImage imageNamed:@"verification1.png"];
    
    [self.view addSubview:verificationImageView];
    self.verificationTextField = [[UITextField alloc] initWithFrame:CGRectMake(60, 200, 310, 50)];
    self.verificationTextField.placeholder = @"验证码";
    self.verificationTextField.textColor = [UIColor grayColor];
    self.verificationTextField.delegate = self;
    [self.view addSubview:self.verificationTextField];
   // 获取验证码
    UIButton *getVerificationButton = [UIButton buttonWithType:UIButtonTypeCustom];
    getVerificationButton.frame = CGRectMake(200, 200, 100, 50);
    [getVerificationButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    [getVerificationButton setTitleColor:[UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [getVerificationButton addTarget:self action:@selector(getVerificationButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:getVerificationButton];
    
    UILabel *verificationLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 260, self.view.frame.size.width - 30, 1)];
    verificationLabel.backgroundColor = [UIColor grayColor];
    verificationLabel.alpha = 0.5;
    [self.view addSubview:verificationLabel];
  //下一步
    UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
    nextButton.frame = CGRectMake(20, 280, self.view.frame.size.width - 40, 40);
    nextButton.backgroundColor = [UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00];
    nextButton.layer.cornerRadius = 4;
    [nextButton setTitle:@"下一步" forState:UIControlStateNormal];
    [nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [nextButton addTarget:self action:@selector(nextButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:nextButton];
  //邮箱登录
    UILabel *emailLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 330, 200, 50)];
    emailLabel.text = @"邮箱用户找回密码，请";
    emailLabel.textColor = [UIColor grayColor];
    [self.view addSubview:emailLabel];
    UIButton *emailLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    emailLoginButton.frame = CGRectMake(220, 330, 100, 50);
    [emailLoginButton setTitle:@"点击这里" forState:UIControlStateNormal];
    [emailLoginButton setTitleColor:[UIColor colorWithRed:0.00 green:0.68 blue:0.53 alpha:1.00] forState:UIControlStateNormal];
    [emailLoginButton addTarget:self action:@selector(emailLoginButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:emailLoginButton];
}
- (void)backToLoginButtonClicked {
    [self.phoneTextField resignFirstResponder];
    [self.verificationTextField resignFirstResponder];
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)getVerificationButtonClicked {
  
}
- (void)nextButtonClicked {
    
}
- (void)emailLoginButtonClicked {
    
}

//收起键盘
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if (![self.phoneTextField isExclusiveTouch] | ![self.verificationTextField isExclusiveTouch]) {
        [self.phoneTextField resignFirstResponder];
        [self.verificationTextField resignFirstResponder];
    }
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField endEditing:YES];
    return YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
